{extend name="layout" /}
{block name="content"}
<div class="mui-content">
	<div class="tm-label tm-bg-white">
		<div class="main-content">
			<div class="tm-flex">
				<div class="tm-icon-item">
					<div class="tm-icon">
						<img src="{$images_path}amount.png" alt="" width="16" height="16" />
					</div>
					<div class="tm-icon-label">
						当前积分：{$uinfo.jifen}
					</div>
				</div>
				<div class="tm-icon-item" style="position: absolute; right: 12px;">
					<div>
						<a class="mui-btn mui-btn-green href" href="{:url('exchange_record', ['token'=>$token, 'timestamp'=>time()])}" style="font-size: 12px;padding: 1px 2px;background-color: white;color: #84c225;">
							积分记录
						</a>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="uk-margin-small-top tm-df-size">
		<div class="tm-label tm-bg-white">
			<div class="main-content">
				<div class="after-title">
					<span>最新单品</span>
				</div>
			</div>
		</div>
		<div class="tm-bg-white">
			<div class="main-content">
				<div class="goods-cell">
					<ul class="uk-grid">
						{volist name=":get_model_func('Convert', 'list_data', ['kucun'=>['gt', 0], 'enddate'=>['egt', date('Y-m-d', SYS_TIME)]])" id="v"}
						<li class="uk-width-1-2">
							<div class="uk-clearfix">
								<a href="{:url('exchange_detail', ['id'=>$v.id]) . '&token=' . $token . '&timestamp=' . time()}" class="tm-atav href">
									<div class="tm-location-parent">
										<div class="tm-location-img" style="background-image: url({$v.thumb});"></div>
										<img class="redundant-img" src="{$images_path}px-1.png" alt="" width="100">
									</div>
								</a>
								<div class="tm-label">
									<div class="tm-flex-row-xs">
										<div class="tm-inline-1-3">
											{$v.title}
										</div>
									</div>
									<div class="tm-flex-row-xs">
										<div class="tm-flex flex-align-center">
											<div class="tm-flex-1">
												<span class="tm-font-yellow">{$v.price}积分</span>
											</div>
											<div>
												<button type="button" class="mui-btn mui-btn-green" onclick="exchange({$v.id})" {eq name="v.kucun" value="0"} disabled {/eq}>兑换</button>
											</div>
										</div>
									</div>
								</div>
							</div>
						</li>
						{/volist}
					</ul>
				</div>
			</div>
		</div>
	</div>
</div>
<div id="layer" style="display: none;">
	<div class="tm-layer-header tm-default-size tm-font-default">
		<div class="tm-label-lg">
			<div class="main-content">
				<div class="tm-inline-1-5 tm-df-size tm-font-bold">
					确认要兑换该商品吗？
				</div>
			</div>
		</div>
	</div>
	<div class="tm-layer-body">
		<div class="main-content">
			<input type="password" class="tm-small-input" value="" placeholder="输入登录密码确认" name="password" id="password" />
		</div>
	</div>
	<div class="tm-layer-footer">
		<div class="tm-label-lg">
			<div class="main-content-md">
				<div class="to-btn-group">
					<ul class="uk-grid">
						<li class="uk-width-1-2">
							<button id="close-layer" type="button" class="mui-btn mui-btn-block">取消</button>
						</li>
						<li class="uk-width-1-2">
							<button type="button" class="mui-btn mui-btn-green mui-btn-block cocoAjax" ajax-url="{:url('v1/adminuser/check_pwd')}" ajax-data="func" datafun="get_data" ajax-callback="suc_back">确定</button>
						</li>
					</ul>
				</div>
			</div>
		</div>
	</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
	var goods_id;
	function exchange(id) {
		layer.open({
			type: 1,
			title: false,
			closeBtn: 0,
			skin: 'tm-page-layer',
			shade: 0.5,
			shadeClose: true,
			content: $('#layer')
		});
		goods_id = id;
	}
	function get_data() {
		var datajson = {};
		var password = $("#password").val();
		if (!password) {
			coco_msg('密码不能为空');
			return false;
		}
		datajson.password = password;
		datajson.goods_id = goods_id;
		return datajson;
	}
	function suc_back(obj, data) {
		location.href = "{$app_url}/index/member/choose_address/goods_id/"+goods_id+"?token="+token+"&timestamp="+{:time()};
	}
    // $(function(){
    //     c3_navtive_user.right_button_item1 = {
    //         title:"兑换记录",
    //         callback:function(){
    //             var content = new Array();
    //             content['url'] = "{$app_url}/index/member/exchange_record";
    //             content['target'] = "blank";
    //             c3_navtive_user.doActionAnsy('gotopage',content,function(){});
    //         }
    //     };
    //     var button_item = [
    //         {
    //             title: "兑换记录",
    //             returnTag:'1'
    //         }
    //     ];
    //     {if !isset($isphone)}
    //         c3_navtive_user.doActionFunc("configMenu",button_item,function(datas){
    //             returntag = eval('(' + datas + ')');
    //             if(returntag.returnTag == 1){
    //                 var content = new Array();
	   //              content['url'] = "{$app_url}/index/member/exchange_record";
	   //              content['target'] = "blank";
	   //              c3_navtive_user.doActionAnsy('gotopage',content,function(){});
    //             }
    //             else if(returntag.returnTag == 2){
    //                 c3_navtive_user.doActionAnsy('openSearch',null,function(){});
    //             }
    //         });
    //     {/if}
    // })
</script>
<script type="text/javascript">
	//关闭
	mui(document).on("tap", "#close-layer", function() {
		layer.closeAll();
	})
</script>
{/block}